import re


class PePvcTube:

    def __init__(self, sel, inse):
        self.sel = sel
        self.inse = inse

    # "子管","PE管","pvc管","pe管","PVC管","钢管","出土管"
    def select(self):
        if self.sel in ("子管"):
            if self.selectHole() in ("1孔", "一孔"):
                return 33
            elif self.selectHole() in ("3孔", "三孔"):
                return 34
            elif self.selectHole() in ("4孔", "四孔"):
                return 35
        elif self.sel in ("pe管", "PE管"):
            return 46
            # if self.selectHole in ("4孔", "四孔"):
            #     if self.selectSand() in ("砂石"):
            #         return 36
            #     elif self.selectSand() in ("混凝土"):
            #         return 37
            #     elif self.selectSand() in ("柏油"):
            #         return 38
            # elif self.selectHole in ("1孔", "一孔"):
            #     if self.selectR() in ("φ50"):
            #         if self.selectSand() in ("砂石"):
            #             return 39
            #         elif self.selectSand() in ("混凝土", "柏油"):
            #             return 40
            #     elif self.selectR() in ("φ100", "φ110"):
            #         if self.selectSand() in ("砂石"):
            #             return 41
            #         elif self.selectSand() in ("混凝土"):
            #             return 42
            #         elif self.selectSand() in ("柏油"):
            #             return 43
            # elif self.selectHole in ("2孔", "二孔", "两孔"):
            #     if self.selectR() in ("φ50"):
            #         if self.selectSand() in ("砂石"):
            #             return 44
            #         elif self.selectSand() in ("混凝土", "柏油"):
            #             return 45
            #     elif self.selectR() in ("φ100", "φ110"):
            #         if self.selectSand() in ("砂石"):
            #             return 46
            #         elif self.selectSand() in ("混凝土"):
            #             return 47
            #         elif self.selectSand() in ("柏油"):
            #             return 48
        elif self.sel in ("pvc管", "PVC管"):
            if self.selectR() in ("φ25"):
                return 49
            elif self.selectR() in ("φ32"):
                return 50
            elif self.selectR() in ("φ40"):
                return 51
            elif self.selectR() in ("φ50"):
                return 52
            elif self.selectR() in ("φ75"):
                return 53
            elif self.selectR() in ("φ110"):
                return 54
        elif self.sel in ("钢管"):
            if self.selectHole() in ("1孔", "一孔"):
                if self.selectR() in ("φ50"):
                    if self.selectSand() in ("砂石"):
                        return 55
                    elif self.selectSand() in ("混凝土"):
                        return 56
                    elif self.selectSand() in ("柏油"):
                        return 57
                elif self.selectR() in ("φ89"):
                    if self.selectSand() in ("砂石"):
                        return 58
                    elif self.selectSand() in ("混凝土"):
                        return 59
                    elif self.selectSand() in ("柏油"):
                        return 60
                elif self.selectR() in ("φ102"):
                    if self.selectSand() in ("砂石"):
                        return 61
                    elif self.selectSand() in ("混凝土"):
                        return 62
                    elif self.selectSand() in ("柏油"):
                        return 63
            elif self.selectHole() in ("2孔", "二孔", "两孔"):
                if self.selectR() in ("φ50"):
                    if self.selectSand() in ("砂石"):
                        return 64
                    elif self.selectSand() in ("混凝土"):
                        return 65
                    elif self.selectSand() in ("柏油"):
                        return 66
                elif self.selectR() in ("φ89"):
                    if self.selectSand() in ("砂石"):
                        return 67
                    elif self.selectSand() in ("混凝土"):
                        return 68
                    elif self.selectSand() in ("柏油"):
                        return 69
                elif self.selectR() in ("φ102"):
                    if self.selectSand() in ("砂石"):
                        return 70
                    elif self.selectSand() in ("混凝土"):
                        return 71
                    elif self.selectSand() in ("柏油"):
                        return 72
        elif self.sel in ("出土管"):
            if self.selectR() in ("φ50"):
                return 73
            elif self.selectR() in ("φ89"):
                return 74

    """判断子管孔数"""

    def selectHole(self):
        try:
            sel = re.findall("1孔|一孔|3孔|三孔|4孔|四孔|2孔|二孔|两孔", self.inse)[0]
            return sel
        except:
            print("孔数未标注")

    """判断管道直径"""

    def selectR(self):
        try:
            sel = re.findall("φ\d*", self.inse)[0]
            return sel
        except:
            print("管孔直径未标注")

    """判断管道直径"""

    def selectThickness(self):
        try:
            sel = re.findall("\d*mm|\d*毫米", self.inse)[0]
            return sel
        except:
            print("钢管厚度未标注")

    """判断砂石水泥柏油"""

    def selectSand(self):
        try:
            sel = re.findall("砂石|混凝土|柏油", self.inse)[0]
            return sel
        except:
            return "砂石"

    def getPePvcTube(self):
        return self.select()
